package net.kong.sns.rest.client.friend;

import java.util.ArrayList;
import java.util.List;

import net.kong.sns.rest.client.InvalidResponseException;
import net.kong.sns.rest.client.KongApiMethod;
import net.kong.sns.rest.client.method.JsonMethodInvokeBase;
import net.kong.sns.rest.client.rest.HttpResponseContent;


/**
 * @author yk
 * @version $Id: GetFriendsSimpleMethodInvoker.java,v 1.3 2009/11/04 17:17:38 ningyubin Exp $
 */
public class GetFriendsSimpleMethodInvoker extends JsonMethodInvokeBase<List<Long>>{

    public GetFriendsSimpleMethodInvoker(KongApiMethod method, String sessionKey,Long user_id) {
        super(method, sessionKey);
        if (user_id != null) setParameter("user_id", user_id.toString());
        setParameter("format", "0");
    }
    
    public GetFriendsSimpleMethodInvoker(KongApiMethod method, String sessionKey) {
        super(method, sessionKey);
        setParameter("format", "0");
    }

    @Override
    protected List<Long> processJsonResponse(HttpResponseContent responseData) throws InvalidResponseException {
        String response = responseData.getBody();
        Object o = reader.read(response);
        List<Number> resultList = (List<Number>) o;
        if (resultList.size() > 0) {
            List<Long> ret=new ArrayList<Long>();
            for(Number userid:resultList){
                ret.add(userid.longValue());
            }
            return ret;
        }
        return null;
    }

}
